/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package publisher;

/**
 *
 * @author jfernan
 */

// from  http://www.jmock.org/getting-started.html

// from http://atunit.googlecode.com/svn/trunk/doc/api/atunit/example/ExampleJMockTest.java.xhtml

import atunit.AtUnit;
import atunit.Mock;
import atunit.MockFramework;
import atunit.Unit;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;


@RunWith(AtUnit.class)
@MockFramework(MockFramework.Option.JMOCK) // use JMock for mock objects
public class PublisherTest_atunit_jmock {



     @Unit IPublisher publisher;

     @Mock Subscriber subscriber;
     Mockery context; // = new JUnit4Mockery();


    @Before
    public void setUp() {
        publisher = new Publisher();
        subscriber = context.mock(Subscriber.class);
    }

    @Test
    public void oneSubscriberReceivesAMessage() {
        // set up

        publisher.add(subscriber);

        final String message = "message";

        // expectations
        context.checking(new Expectations() {{
            oneOf (subscriber).receive(message);
        }});

        // execute
        publisher.publish(message);



    }


}
